Skip to content

Conversation

@alexcarpenter
Copy link
Member

@alexcarpenter alexcarpenter commented Oct 31, 2025

Description

  • Introduces a live region that updates when feedback changes to ensure messages are read live to the user as they change
  • Preserves aria-describeby to ensure when tabbing through fields that the feedback message is read on focus

Why Both Are Needed

  • Visually hidden element: Provides real-time announcements as you type (via aria-live)
  • Visual elements: Provide context when navigating - when a screen reader user tabs to the password field, it reads: "Password field, [error message]" using the aria-describedby connection

So you get:

  • While typing: "Password too short" → "Add uppercase letters" (from live region)
  • When focusing field: "Password, Password too short" (from aria-describedby)

fixes USER-3837

Testing

  1. open VO and within the password input, start typing to trigger the different feedback
    • acceptance: the contents of the feedback should be immediately read to screen reader
  2. submit an invalid form which renders error feedback on fields. open VO and tab through the fields
    • acceptance: the error messages should be read on focus due to the aria-describedby connection to the inputs
Screen.Recording.2025-10-31.at.1.45.07.PM.mov

Checklist

  • pnpm test runs as expected.
  • pnpm build runs as expected.
  • (If applicable) JSDoc comments have been added or updated for any package exports
  • (If applicable) Documentation has been updated

Type of change

  • 🐛 Bug fix
  • 🌟 New feature
  • 🔨 Breaking change
  • 📖 Refactoring / dependency upgrade / documentation
  • other:

Summary by CodeRabbit

Release Notes

New Features

  • Implemented screen reader live regions to automatically announce feedback messages (errors, warnings, and informational content) when they appear or update on forms

Tests

  • Refactored test suite to rely on explicit test IDs for feedback element queries instead of text-based selectors, improving test robustness across form controls, sign-in, sign-up, and password recovery flows

@changeset-bot
Copy link

changeset-bot bot commented Oct 31, 2025

🦋 Changeset detected

Latest commit: d5d226a

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 3 packages
Name Type
@clerk/clerk-js Patch
@clerk/chrome-extension Patch
@clerk/clerk-expo Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@vercel
Copy link

vercel bot commented Oct 31, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
clerk-js-sandbox Ready Ready Preview Comment Nov 6, 2025 4:06am

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 31, 2025

Walkthrough

This change improves screen reader accessibility by adding a centralized aria-live region to the FormControl component to announce feedback message changes. Corresponding tests across unit and integration test suites have been updated to query form feedback elements using dedicated test IDs instead of text content matchers.

Changes

Cohort / File(s) Summary
Changeset Documentation
.changeset/puny-places-shine.md
Records a patch release for @clerk/clerk-js documenting the addition of aria-live region for form feedback announcements.
Core Accessibility Enhancement
packages/clerk-js/src/ui/elements/FormControl.tsx
Adds a screen-reader live region (aria-live="polite") using Span component to centralize and announce feedback changes, replacing per-component aria-live approach. Adds data-testid attributes to feedback components.
Unit Test Updates
packages/clerk-js/src/ui/elements/__tests__/PlainInput.test.tsx, packages/clerk-js/src/ui/elements/__tests__/RadioGroup.test.tsx, packages/clerk-js/src/ui/components/SignIn/__tests__/SignInFactorOne.test.tsx, packages/clerk-js/src/ui/components/SignIn/__tests__/SignInFactorTwo.test.tsx, packages/clerk-js/src/ui/components/SignIn/__tests__/ResetPassword.test.tsx, packages/clerk-js/src/ui/components/SignUp/__tests__/SignUpContinue.test.tsx, packages/clerk-js/src/ui/components/UserProfile/__tests__/PasswordSection.test.tsx
Test assertions refactored to locate form feedback elements via test IDs (form-feedback-error, form-feedback-info, form-feedback-success) instead of text content queries; verifies aria-live region presence and behavior.
Integration Test Updates
integration/tests/sign-in-flow.test.ts, integration/tests/sign-in-or-up-flow.test.ts, integration/tests/sign-up-flow.test.ts, integration/tests/sign-in-or-up-restricted-mode.test.ts
Error message assertions updated to query form-feedback-error element by test ID and validate text content, replacing generic text-based element queries.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Input as Form Input
    participant FC as FormControl<br/>(FormControl.tsx)
    participant LR as aria-live Region
    participant SR as Screen Reader

    User->>Input: Submits form / Changes value
    Input->>FC: Updates feedback state
    FC->>FC: Renders live region & feedback
    FC->>LR: Updates live region content<br/>(aria-live="polite")
    activate LR
    LR->>SR: Announces feedback message<br/>(on next async cycle)
    SR->>User: "Error: Password incorrect"
    deactivate LR
    FC->>Input: Displays feedback UI
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20–30 minutes

  • FormControl.tsx production change: Verify aria-live region implementation (placement, attributes, styling), Span component integration, and that test ID data attributes are correctly applied.
  • Test pattern consistency: While highly homogeneous across 11+ files, cross-check that the form-feedback-error, form-feedback-info, and form-feedback-success test IDs are actually declared in component implementations.
  • aria-live behavior validation: Ensure test assertions correctly validate aria-live region presence, polite mode, atomic attribute, and visual-hiding for screen-reader-only announcements.

Poem

🐰 A live region hops into place,
Aria-live now shows its grace,
Screen readers rejoice with glee,
"Error messages are heard," decree!
No more silent feedback's trace—
Accessibility wins the race! 🎉

Pre-merge checks and finishing touches

✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and specifically describes the main change: adding screen reader support for error announcements in clerk-js forms.
Linked Issues check ✅ Passed The PR implements both requirements from USER-3837: adds aria-live region for real-time feedback announcements and preserves aria-describedby for contextual feedback on focus.
Out of Scope Changes check ✅ Passed All changes are directly scoped to implementing screen reader accessibility for form errors as specified in USER-3837; no unrelated modifications detected.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch alexcarpenter/user-3837-form-errors-not-being-announced-by-screen-readers

Comment @coderabbitai help to get the list of available commands and usage tips.

@alexcarpenter
Copy link
Member Author

!snapshot

@clerk-cookie
Copy link
Collaborator

Hey @alexcarpenter - the snapshot version command generated the following package versions:

Package Version
@clerk/agent-toolkit 0.1.45-snapshot.v20251031161044
@clerk/astro 2.14.3-snapshot.v20251031161044
@clerk/backend 2.19.2-snapshot.v20251031161044
@clerk/chrome-extension 2.7.11-snapshot.v20251031161044
@clerk/clerk-js 5.103.2-snapshot.v20251031161044
@clerk/elements 0.23.76-snapshot.v20251031161044
@clerk/clerk-expo 2.17.4-snapshot.v20251031161044
@clerk/expo-passkeys 0.4.13-snapshot.v20251031161044
@clerk/express 1.7.44-snapshot.v20251031161044
@clerk/fastify 2.5.1-snapshot.v20251031161044
@clerk/localizations 3.26.5-snapshot.v20251031161044
@clerk/nextjs 6.34.2-snapshot.v20251031161044
@clerk/nuxt 1.11.3-snapshot.v20251031161044
@clerk/clerk-react 5.53.5-snapshot.v20251031161044
@clerk/react-router 2.1.7-snapshot.v20251031161044
@clerk/remix 4.13.10-snapshot.v20251031161044
@clerk/shared 3.30.0-snapshot.v20251031161044
@clerk/tanstack-react-start 0.26.6-snapshot.v20251031161044
@clerk/testing 1.13.10-snapshot.v20251031161044
@clerk/themes 2.4.31-snapshot.v20251031161044
@clerk/types 4.97.0-snapshot.v20251031161044
@clerk/vue 1.14.10-snapshot.v20251031161044

Tip: Use the snippet copy button below to quickly install the required packages.
@clerk/agent-toolkit

npm i @clerk/[email protected] --save-exact

@clerk/astro

npm i @clerk/[email protected] --save-exact

@clerk/backend

npm i @clerk/[email protected] --save-exact

@clerk/chrome-extension

npm i @clerk/[email protected] --save-exact

@clerk/clerk-js

npm i @clerk/[email protected] --save-exact

@clerk/elements

npm i @clerk/[email protected] --save-exact

@clerk/clerk-expo

npm i @clerk/[email protected] --save-exact

@clerk/expo-passkeys

npm i @clerk/[email protected] --save-exact

@clerk/express

npm i @clerk/[email protected] --save-exact

@clerk/fastify

npm i @clerk/[email protected] --save-exact

@clerk/localizations

npm i @clerk/[email protected] --save-exact

@clerk/nextjs

npm i @clerk/[email protected] --save-exact

@clerk/nuxt

npm i @clerk/[email protected] --save-exact

@clerk/clerk-react

npm i @clerk/[email protected] --save-exact

@clerk/react-router

npm i @clerk/[email protected] --save-exact

@clerk/remix

npm i @clerk/[email protected] --save-exact

@clerk/shared

npm i @clerk/[email protected] --save-exact

@clerk/tanstack-react-start

npm i @clerk/[email protected] --save-exact

@clerk/testing

npm i @clerk/[email protected] --save-exact

@clerk/themes

npm i @clerk/[email protected] --save-exact

@clerk/types

npm i @clerk/[email protected] --save-exact

@clerk/vue

npm i @clerk/[email protected] --save-exact

Copy link

@Ephem Ephem left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great, thanks for fixing this!

Comment on lines 239 to 241
// Verify there's a screen-reader-only aria-live region with the error content
const ariaLiveRegions = container.querySelectorAll('[aria-live="polite"]');
expect(ariaLiveRegions.length).toBeGreaterThanOrEqual(1);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NIT: If I understood the bug correctly, the announcement did not work because aria-live only announces changes to the DOM element, so maybe this test should also assert that this element is already in the DOM without errors before the set error?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Ephem I updated the tests, let me know what you think!

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like it! They feel tightly scoped now, and like they would catch any regression. 👍

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (2)
packages/clerk-js/src/ui/elements/__tests__/PlainInput.test.tsx (2)

235-248: Pre-state validation addresses past feedback, but consider stricter assertions.

The pre-state validation correctly addresses the previous review comment about verifying the aria-live region exists before content changes. This ensures the region can announce updates properly.

However, line 237 uses toBeGreaterThanOrEqual(1), which is lenient. If the implementation accidentally creates multiple aria-live regions, this test would still pass. Consider whether you should assert an exact count to catch regressions.

-    expect(preRegions.length).toBeGreaterThanOrEqual(1);
+    expect(preRegions.length).toBe(1);

254-282: Consider strengthening assertions for completeness.

The test correctly validates the screen-reader-only live region updates, but could be more comprehensive:

  1. Reuse pre-state region: Lines 259-262 re-query for the screen-reader-only region. Consider reusing preSrOnly from the pre-state validation (lines 238-242) to ensure you're testing the same element throughout.

  2. Verify aria-describedby transitions: The test validates the live region content but doesn't check that the input's aria-describedby attribute correctly transitions from error-firstname to firstname-success-feedback. This is covered in other tests, but including it here would make this test more self-contained.

  3. Same leniency issue: Line 256 uses toBeGreaterThanOrEqual(1) which could mask duplicate regions.

-    const ariaLiveRegions = container.querySelectorAll('[aria-live="polite"]');
-    expect(ariaLiveRegions.length).toBeGreaterThanOrEqual(1);
-
-    // Find the screen reader only region (it will have the visually hidden styles)
-    const srOnlyRegion = Array.from(ariaLiveRegions).find(el => {
-      const style = window.getComputedStyle(el);
-      return style.position === 'absolute' && style.width === '1px';
-    });
-    expect(srOnlyRegion).toBeDefined();
+    // Reuse the pre-state region to ensure consistency
+    expect(preSrOnly).toBeDefined();
+    const srOnlyRegion = preSrOnly!;
     expect(srOnlyRegion).toHaveTextContent(/Some Error/i);
+    
+    // Verify input aria-describedby references the error
+    expect(inputEl).toHaveAttribute('aria-describedby', 'error-firstname');
+    expect(inputEl).toHaveAttribute('aria-invalid', 'true');

And after the success transition:

     // Verify the screen reader only region updated its content
     expect(srOnlyRegion).toHaveTextContent(/Some Success/i);
+    
+    // Verify input aria-describedby references the success feedback
+    expect(inputEl).toHaveAttribute('aria-describedby', 'firstname-success-feedback');
+    expect(inputEl).toHaveAttribute('aria-invalid', 'false');
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between ab795fb and b3ea687.

📒 Files selected for processing (1)
  • packages/clerk-js/src/ui/elements/__tests__/PlainInput.test.tsx (6 hunks)
🧰 Additional context used
📓 Path-based instructions (13)
packages/clerk-js/src/ui/**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/clerk-js-ui.mdc)

packages/clerk-js/src/ui/**/*.{ts,tsx}: Element descriptors should always be camelCase
Use element descriptors in UI components to enable consistent theming and styling via appearance.elements
Element descriptors should generate unique, stable CSS classes for theming
Element descriptors should handle state classes (e.g., cl-loading, cl-active, cl-error, cl-open) automatically based on component state
Do not render hard-coded values; all user-facing strings must be localized using provided localization methods
Use the useLocalizations hook and localizationKeys utility for all text and error messages
Use the styled system (sx prop, theme tokens, responsive values) for custom component styling
Use useCardState for card-level state, useFormState for form-level state, and useLoadingStatus for loading states
Always use handleError utility for API errors and use translateError for localized error messages
Use useFormControl for form field state, implement proper validation, and handle loading and error states in forms
Use localization keys for all form labels and placeholders
Use element descriptors for consistent styling and follow the theme token system
Use the Card and FormContainer patterns for consistent UI structure

Files:

  • packages/clerk-js/src/ui/elements/__tests__/PlainInput.test.tsx
**/*.{js,jsx,ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

**/*.{js,jsx,ts,tsx}: All code must pass ESLint checks with the project's configuration
Follow established naming conventions (PascalCase for components, camelCase for variables)
Maintain comprehensive JSDoc comments for public APIs
Use dynamic imports for optional features
All public APIs must be documented with JSDoc
Provide meaningful error messages to developers
Include error recovery suggestions where applicable
Log errors appropriately for debugging
Lazy load components and features when possible
Implement proper caching strategies
Use efficient data structures and algorithms
Profile and optimize critical paths
Validate all inputs and sanitize outputs
Implement proper logging with different levels

Files:

  • packages/clerk-js/src/ui/elements/__tests__/PlainInput.test.tsx
**/*.{js,jsx,ts,tsx,json,css,scss,md,yaml,yml}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

Use Prettier for consistent code formatting

Files:

  • packages/clerk-js/src/ui/elements/__tests__/PlainInput.test.tsx
packages/**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

TypeScript is required for all packages

Files:

  • packages/clerk-js/src/ui/elements/__tests__/PlainInput.test.tsx
packages/**/*.{ts,tsx,d.ts}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

Packages should export TypeScript types alongside runtime code

Files:

  • packages/clerk-js/src/ui/elements/__tests__/PlainInput.test.tsx
**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

Use proper TypeScript error types

**/*.{ts,tsx}: Always define explicit return types for functions, especially public APIs
Use proper type annotations for variables and parameters where inference isn't clear
Avoid any type - prefer unknown when type is uncertain, then narrow with type guards
Use interface for object shapes that might be extended
Use type for unions, primitives, and computed types
Prefer readonly properties for immutable data structures
Use private for internal implementation details
Use protected for inheritance hierarchies
Use public explicitly for clarity in public APIs
Prefer readonly for properties that shouldn't change after construction
Prefer composition and interfaces over deep inheritance chains
Use mixins for shared behavior across unrelated classes
Implement dependency injection for loose coupling
Let TypeScript infer when types are obvious
Use const assertions for literal types: as const
Use satisfies operator for type checking without widening
Use mapped types for transforming object types
Use conditional types for type-level logic
Leverage template literal types for string manipulation
Use ES6 imports/exports consistently
Use default exports sparingly, prefer named exports
Use type-only imports: import type { ... } from ...
No any types without justification
Proper error handling with typed errors
Consistent use of readonly for immutable data
Proper generic constraints
No unused type parameters
Proper use of utility types instead of manual type construction
Type-only imports where possible
Proper tree-shaking friendly exports
No circular dependencies
Efficient type computations (avoid deep recursion)

Files:

  • packages/clerk-js/src/ui/elements/__tests__/PlainInput.test.tsx
**/*.{jsx,tsx}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

**/*.{jsx,tsx}: Use error boundaries in React components
Minimize re-renders in React components

**/*.{jsx,tsx}: Always use functional components with hooks instead of class components
Follow PascalCase naming for components: UserProfile, NavigationMenu
Keep components focused on a single responsibility - split large components
Limit component size to 150-200 lines; extract logic into custom hooks
Use composition over inheritance - prefer smaller, composable components
Export components as named exports for better tree-shaking
One component per file with matching filename and component name
Use useState for simple state management
Use useReducer for complex state logic
Implement proper state initialization
Use proper state updates with callbacks
Implement proper state cleanup
Use Context API for theme/authentication
Implement proper state selectors
Use proper state normalization
Implement proper state persistence
Use React.memo for expensive components
Implement proper useCallback for handlers
Use proper useMemo for expensive computations
Implement proper virtualization for lists
Use proper code splitting with React.lazy
Implement proper cleanup in useEffect
Use proper refs for DOM access
Implement proper event listener cleanup
Use proper abort controllers for fetch
Implement proper subscription cleanup
Use proper HTML elements
Implement proper ARIA attributes
Use proper heading hierarchy
Implement proper form labels
Use proper button types
Implement proper focus management
Use proper keyboard shortcuts
Implement proper tab order
Use proper skip links
Implement proper focus traps
Implement proper error boundaries
Use proper error logging
Implement proper error recovery
Use proper error messages
Implement proper error fallbacks
Use proper form validation
Implement proper error states
Use proper error messages
Implement proper form submission
Use proper form reset
Use proper component naming
Implement proper file naming
Use proper prop naming
Implement proper...

Files:

  • packages/clerk-js/src/ui/elements/__tests__/PlainInput.test.tsx
packages/**/*.{test,spec}.{js,jsx,ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/monorepo.mdc)

Unit tests should use Jest or Vitest as the test runner.

Files:

  • packages/clerk-js/src/ui/elements/__tests__/PlainInput.test.tsx
packages/{clerk-js,elements,themes}/**/*.{test,spec}.{js,jsx,ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/monorepo.mdc)

Visual regression testing should be performed for UI components.

Files:

  • packages/clerk-js/src/ui/elements/__tests__/PlainInput.test.tsx
**/*.{js,ts,tsx,jsx}

📄 CodeRabbit inference engine (.cursor/rules/monorepo.mdc)

Support multiple Clerk environment variables (CLERK_, NEXT_PUBLIC_CLERK_, etc.) for configuration.

Files:

  • packages/clerk-js/src/ui/elements/__tests__/PlainInput.test.tsx
**/*.tsx

📄 CodeRabbit inference engine (.cursor/rules/react.mdc)

**/*.tsx: Use proper type definitions for props and state
Leverage TypeScript's type inference where possible
Use proper event types for handlers
Implement proper generic types for reusable components
Use proper type guards for conditional rendering

Files:

  • packages/clerk-js/src/ui/elements/__tests__/PlainInput.test.tsx
**/*.test.{jsx,tsx}

📄 CodeRabbit inference engine (.cursor/rules/react.mdc)

**/*.test.{jsx,tsx}: Use React Testing Library
Test component behavior, not implementation
Use proper test queries
Implement proper test isolation
Use proper test coverage
Test component interactions
Use proper test data
Implement proper test setup
Use proper test cleanup
Implement proper test assertions
Use proper test structure

Files:

  • packages/clerk-js/src/ui/elements/__tests__/PlainInput.test.tsx
**/__tests__/**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/typescript.mdc)

**/__tests__/**/*.{ts,tsx}: Create type-safe test builders/factories
Use branded types for test isolation
Implement proper mock types that match interfaces

Files:

  • packages/clerk-js/src/ui/elements/__tests__/PlainInput.test.tsx
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
  • GitHub Check: Formatting | Dedupe | Changeset
  • GitHub Check: Analyze (javascript-typescript)
  • GitHub Check: semgrep-cloud-platform/scan
  • GitHub Check: semgrep-cloud-platform/scan
🔇 Additional comments (2)
packages/clerk-js/src/ui/elements/__tests__/PlainInput.test.tsx (2)

142-142: LGTM! Precise ID-based selectors improve test reliability.

The updated selectors now target specific IDs (#error-firstname, #firstname-info-feedback, #firstname-success-feedback) which align with the accessibility improvements in the PR. These precise selectors reduce brittleness and ensure tests verify the correct ARIA-described elements.

Also applies to: 166-166, 181-181, 205-205, 213-213, 252-252, 268-268


225-225: LGTM! More descriptive test name.

The renamed test case better describes the accessibility implementation: a visually hidden live region that announces feedback changes to screen readers in real time.

@pkg-pr-new
Copy link

pkg-pr-new bot commented Nov 4, 2025

Open in StackBlitz

@clerk/agent-toolkit

npm i https://pkg.pr.new/@clerk/agent-toolkit@7111

@clerk/astro

npm i https://pkg.pr.new/@clerk/astro@7111

@clerk/backend

npm i https://pkg.pr.new/@clerk/backend@7111

@clerk/chrome-extension

npm i https://pkg.pr.new/@clerk/chrome-extension@7111

@clerk/clerk-js

npm i https://pkg.pr.new/@clerk/clerk-js@7111

@clerk/dev-cli

npm i https://pkg.pr.new/@clerk/dev-cli@7111

@clerk/elements

npm i https://pkg.pr.new/@clerk/elements@7111

@clerk/clerk-expo

npm i https://pkg.pr.new/@clerk/clerk-expo@7111

@clerk/expo-passkeys

npm i https://pkg.pr.new/@clerk/expo-passkeys@7111

@clerk/express

npm i https://pkg.pr.new/@clerk/express@7111

@clerk/fastify

npm i https://pkg.pr.new/@clerk/fastify@7111

@clerk/localizations

npm i https://pkg.pr.new/@clerk/localizations@7111

@clerk/nextjs

npm i https://pkg.pr.new/@clerk/nextjs@7111

@clerk/nuxt

npm i https://pkg.pr.new/@clerk/nuxt@7111

@clerk/clerk-react

npm i https://pkg.pr.new/@clerk/clerk-react@7111

@clerk/react-router

npm i https://pkg.pr.new/@clerk/react-router@7111

@clerk/remix

npm i https://pkg.pr.new/@clerk/remix@7111

@clerk/shared

npm i https://pkg.pr.new/@clerk/shared@7111

@clerk/tanstack-react-start

npm i https://pkg.pr.new/@clerk/tanstack-react-start@7111

@clerk/testing

npm i https://pkg.pr.new/@clerk/testing@7111

@clerk/themes

npm i https://pkg.pr.new/@clerk/themes@7111

@clerk/types

npm i https://pkg.pr.new/@clerk/types@7111

@clerk/upgrade

npm i https://pkg.pr.new/@clerk/upgrade@7111

@clerk/vue

npm i https://pkg.pr.new/@clerk/vue@7111

commit: d5d226a

@blacksmith-sh

This comment has been minimized.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
packages/clerk-js/src/ui/components/SignIn/__tests__/SignInFactorTwo.test.tsx (2)

164-196: Critical: Error message mismatch causes test to always use fallback path.

The mocked error returns "Incorrect phone code" (line 178), but the test searches for "Incorrect authenticator code" (line 189). This mismatch means the text search will always fail, and the test will always fall through to the data-error attribute check, defeating the purpose of the dual-path verification.

Apply this diff to fix the error message:

     await userEvent.type(screen.getByLabelText(/Enter verification code/i), '123456');
     try {
-      await screen.findByText(/Incorrect authenticator code/i, { selector: '[id^="error-"]' });
+      await screen.findByText(/Incorrect phone code/i, { selector: '[id^="error-"]' });
     } catch {
       // Fallback: check for error state attribute if text element doesn't exist
       await waitFor(() => {

261-292: Critical: Error message mismatch causes test to always use fallback path.

The mocked error returns "Incorrect authenticator code" (line 274), but the test searches for "Incorrect phone code" (line 285). This mismatch means the text search will always fail, causing the test to always fall through to the data-error attribute check.

Apply this diff to fix the error message:

     await userEvent.type(screen.getByLabelText(/Enter verification code/i), '123456');
     try {
-      await screen.findByText(/Incorrect phone code/i, { selector: '[id^="error-"]' });
+      await screen.findByText(/Incorrect authenticator code/i, { selector: '[id^="error-"]' });
     } catch {
       // Fallback: check for error state attribute if text element doesn't exist
       await waitFor(() => {
🧹 Nitpick comments (3)
integration/tests/elements/next-sign-in.test.ts (1)

185-186: Consider extracting the assertion pattern to reduce duplication.

The same assertion pattern (locator('#error-password').toBeVisible() + toHaveText()) appears multiple times across this file and other test files. While not critical, extracting this to a helper method would improve maintainability.

Example helper:

async function expectPasswordError(u: TestUtils, pattern: RegExp) {
  await expect(u.page.locator('#error-password')).toBeVisible();
  await expect(u.page.locator('#error-password')).toHaveText(pattern);
}

Then use:

await expectPasswordError(u, /password is incorrect/i);
packages/clerk-js/src/ui/components/SignIn/__tests__/SignInFactorTwo.test.tsx (1)

188-195: Consider simplifying the dual-path error verification pattern.

The try/catch fallback pattern silently masks which assertion path succeeds, making debugging harder when tests fail. This approach suggests uncertainty about how errors are rendered in production.

Consider one of these alternatives:

  1. If both rendering modes are valid, add logging to document which path was taken:
 try {
   await screen.findByText(/Incorrect phone code/i, { selector: '[id^="error-"]' });
 } catch {
-  // Fallback: check for error state attribute if text element doesn't exist
+  console.info('Error text not found, checking data-error attribute');
   await waitFor(() => {
     expect(container.querySelector('[data-error="true"].cl-otpCodeField')).toBeInTheDocument();
   });
 }
  1. If only one rendering mode should be active, assert the expected behavior directly:
-try {
-  await screen.findByText(/Incorrect phone code/i, { selector: '[id^="error-"]' });
-} catch {
-  // Fallback: check for error state attribute if text element doesn't exist
-  await waitFor(() => {
-    expect(container.querySelector('[data-error="true"].cl-otpCodeField')).toBeInTheDocument();
-  });
-}
+// Verify error is announced via live region
+await screen.findByText(/Incorrect phone code/i, { selector: '[id^="error-"]' });
+// Verify error state on field for aria-describedby
+expect(container.querySelector('[data-error="true"].cl-otpCodeField')).toBeInTheDocument();

Based on the PR objectives (adding ARIA live regions while preserving aria-describedby), both checks should likely pass simultaneously rather than being alternatives.

Also applies to: 284-291, 384-391

packages/clerk-js/src/ui/elements/__tests__/PlainInput.test.tsx (1)

235-243: Consider testing behavior over implementation details.

The test checks computed styles (position === 'absolute' and width === '1px') to identify the visually-hidden live region. This tightly couples the test to the current CSS implementation and could break if the visually-hidden utility class changes (e.g., using clip or transform instead).

Consider using a more stable identifier, such as:

  • A data-testid attribute on the live region element
  • An ARIA role or attribute that semantically identifies it
  • Or document that this test will need updates if the sr-only/visually-hidden implementation changes

Example:

-    const srOnlyRegion = Array.from(ariaLiveRegions).find(el => {
-      const style = window.getComputedStyle(el);
-      return style.position === 'absolute' && style.width === '1px';
-    });
+    // Find the live region by data-testid (add data-testid="sr-only-live-region" in implementation)
+    const srOnlyRegion = container.querySelector('[data-testid="sr-only-live-region"][aria-live="polite"]');

Also applies to: 258-264

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between d770878 and ab5466e.

📒 Files selected for processing (11)
  • integration/tests/elements/next-sign-in.test.ts (2 hunks)
  • integration/tests/elements/next-sign-up.test.ts (1 hunks)
  • integration/tests/sign-in-flow.test.ts (2 hunks)
  • integration/tests/sign-in-or-up-flow.test.ts (2 hunks)
  • integration/tests/sign-up-flow.test.ts (1 hunks)
  • packages/clerk-js/src/ui/components/SignIn/__tests__/ResetPassword.test.tsx (2 hunks)
  • packages/clerk-js/src/ui/components/SignIn/__tests__/SignInFactorOne.test.tsx (6 hunks)
  • packages/clerk-js/src/ui/components/SignIn/__tests__/SignInFactorTwo.test.tsx (3 hunks)
  • packages/clerk-js/src/ui/components/UserProfile/__tests__/PasswordSection.test.tsx (2 hunks)
  • packages/clerk-js/src/ui/elements/__tests__/PlainInput.test.tsx (6 hunks)
  • packages/clerk-js/src/ui/elements/__tests__/RadioGroup.test.tsx (4 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • integration/tests/sign-in-flow.test.ts
  • packages/clerk-js/src/ui/components/SignIn/tests/ResetPassword.test.tsx
🧰 Additional context used
📓 Path-based instructions (16)
packages/clerk-js/src/ui/**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/clerk-js-ui.mdc)

packages/clerk-js/src/ui/**/*.{ts,tsx}: Element descriptors should always be camelCase
Use element descriptors in UI components to enable consistent theming and styling via appearance.elements
Element descriptors should generate unique, stable CSS classes for theming
Element descriptors should handle state classes (e.g., cl-loading, cl-active, cl-error, cl-open) automatically based on component state
Do not render hard-coded values; all user-facing strings must be localized using provided localization methods
Use the useLocalizations hook and localizationKeys utility for all text and error messages
Use the styled system (sx prop, theme tokens, responsive values) for custom component styling
Use useCardState for card-level state, useFormState for form-level state, and useLoadingStatus for loading states
Always use handleError utility for API errors and use translateError for localized error messages
Use useFormControl for form field state, implement proper validation, and handle loading and error states in forms
Use localization keys for all form labels and placeholders
Use element descriptors for consistent styling and follow the theme token system
Use the Card and FormContainer patterns for consistent UI structure

Files:

  • packages/clerk-js/src/ui/components/UserProfile/__tests__/PasswordSection.test.tsx
  • packages/clerk-js/src/ui/elements/__tests__/PlainInput.test.tsx
  • packages/clerk-js/src/ui/elements/__tests__/RadioGroup.test.tsx
  • packages/clerk-js/src/ui/components/SignIn/__tests__/SignInFactorOne.test.tsx
  • packages/clerk-js/src/ui/components/SignIn/__tests__/SignInFactorTwo.test.tsx
**/*.{js,jsx,ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

**/*.{js,jsx,ts,tsx}: All code must pass ESLint checks with the project's configuration
Follow established naming conventions (PascalCase for components, camelCase for variables)
Maintain comprehensive JSDoc comments for public APIs
Use dynamic imports for optional features
All public APIs must be documented with JSDoc
Provide meaningful error messages to developers
Include error recovery suggestions where applicable
Log errors appropriately for debugging
Lazy load components and features when possible
Implement proper caching strategies
Use efficient data structures and algorithms
Profile and optimize critical paths
Validate all inputs and sanitize outputs
Implement proper logging with different levels

Files:

  • packages/clerk-js/src/ui/components/UserProfile/__tests__/PasswordSection.test.tsx
  • integration/tests/elements/next-sign-up.test.ts
  • integration/tests/elements/next-sign-in.test.ts
  • integration/tests/sign-up-flow.test.ts
  • packages/clerk-js/src/ui/elements/__tests__/PlainInput.test.tsx
  • packages/clerk-js/src/ui/elements/__tests__/RadioGroup.test.tsx
  • packages/clerk-js/src/ui/components/SignIn/__tests__/SignInFactorOne.test.tsx
  • integration/tests/sign-in-or-up-flow.test.ts
  • packages/clerk-js/src/ui/components/SignIn/__tests__/SignInFactorTwo.test.tsx
**/*.{js,jsx,ts,tsx,json,css,scss,md,yaml,yml}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

Use Prettier for consistent code formatting

Files:

  • packages/clerk-js/src/ui/components/UserProfile/__tests__/PasswordSection.test.tsx
  • integration/tests/elements/next-sign-up.test.ts
  • integration/tests/elements/next-sign-in.test.ts
  • integration/tests/sign-up-flow.test.ts
  • packages/clerk-js/src/ui/elements/__tests__/PlainInput.test.tsx
  • packages/clerk-js/src/ui/elements/__tests__/RadioGroup.test.tsx
  • packages/clerk-js/src/ui/components/SignIn/__tests__/SignInFactorOne.test.tsx
  • integration/tests/sign-in-or-up-flow.test.ts
  • packages/clerk-js/src/ui/components/SignIn/__tests__/SignInFactorTwo.test.tsx
packages/**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

TypeScript is required for all packages

Files:

  • packages/clerk-js/src/ui/components/UserProfile/__tests__/PasswordSection.test.tsx
  • packages/clerk-js/src/ui/elements/__tests__/PlainInput.test.tsx
  • packages/clerk-js/src/ui/elements/__tests__/RadioGroup.test.tsx
  • packages/clerk-js/src/ui/components/SignIn/__tests__/SignInFactorOne.test.tsx
  • packages/clerk-js/src/ui/components/SignIn/__tests__/SignInFactorTwo.test.tsx
packages/**/*.{ts,tsx,d.ts}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

Packages should export TypeScript types alongside runtime code

Files:

  • packages/clerk-js/src/ui/components/UserProfile/__tests__/PasswordSection.test.tsx
  • packages/clerk-js/src/ui/elements/__tests__/PlainInput.test.tsx
  • packages/clerk-js/src/ui/elements/__tests__/RadioGroup.test.tsx
  • packages/clerk-js/src/ui/components/SignIn/__tests__/SignInFactorOne.test.tsx
  • packages/clerk-js/src/ui/components/SignIn/__tests__/SignInFactorTwo.test.tsx
**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

Use proper TypeScript error types

**/*.{ts,tsx}: Always define explicit return types for functions, especially public APIs
Use proper type annotations for variables and parameters where inference isn't clear
Avoid any type - prefer unknown when type is uncertain, then narrow with type guards
Use interface for object shapes that might be extended
Use type for unions, primitives, and computed types
Prefer readonly properties for immutable data structures
Use private for internal implementation details
Use protected for inheritance hierarchies
Use public explicitly for clarity in public APIs
Prefer readonly for properties that shouldn't change after construction
Prefer composition and interfaces over deep inheritance chains
Use mixins for shared behavior across unrelated classes
Implement dependency injection for loose coupling
Let TypeScript infer when types are obvious
Use const assertions for literal types: as const
Use satisfies operator for type checking without widening
Use mapped types for transforming object types
Use conditional types for type-level logic
Leverage template literal types for string manipulation
Use ES6 imports/exports consistently
Use default exports sparingly, prefer named exports
Use type-only imports: import type { ... } from ...
No any types without justification
Proper error handling with typed errors
Consistent use of readonly for immutable data
Proper generic constraints
No unused type parameters
Proper use of utility types instead of manual type construction
Type-only imports where possible
Proper tree-shaking friendly exports
No circular dependencies
Efficient type computations (avoid deep recursion)

Files:

  • packages/clerk-js/src/ui/components/UserProfile/__tests__/PasswordSection.test.tsx
  • integration/tests/elements/next-sign-up.test.ts
  • integration/tests/elements/next-sign-in.test.ts
  • integration/tests/sign-up-flow.test.ts
  • packages/clerk-js/src/ui/elements/__tests__/PlainInput.test.tsx
  • packages/clerk-js/src/ui/elements/__tests__/RadioGroup.test.tsx
  • packages/clerk-js/src/ui/components/SignIn/__tests__/SignInFactorOne.test.tsx
  • integration/tests/sign-in-or-up-flow.test.ts
  • packages/clerk-js/src/ui/components/SignIn/__tests__/SignInFactorTwo.test.tsx
**/*.{jsx,tsx}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

**/*.{jsx,tsx}: Use error boundaries in React components
Minimize re-renders in React components

**/*.{jsx,tsx}: Always use functional components with hooks instead of class components
Follow PascalCase naming for components: UserProfile, NavigationMenu
Keep components focused on a single responsibility - split large components
Limit component size to 150-200 lines; extract logic into custom hooks
Use composition over inheritance - prefer smaller, composable components
Export components as named exports for better tree-shaking
One component per file with matching filename and component name
Use useState for simple state management
Use useReducer for complex state logic
Implement proper state initialization
Use proper state updates with callbacks
Implement proper state cleanup
Use Context API for theme/authentication
Implement proper state selectors
Use proper state normalization
Implement proper state persistence
Use React.memo for expensive components
Implement proper useCallback for handlers
Use proper useMemo for expensive computations
Implement proper virtualization for lists
Use proper code splitting with React.lazy
Implement proper cleanup in useEffect
Use proper refs for DOM access
Implement proper event listener cleanup
Use proper abort controllers for fetch
Implement proper subscription cleanup
Use proper HTML elements
Implement proper ARIA attributes
Use proper heading hierarchy
Implement proper form labels
Use proper button types
Implement proper focus management
Use proper keyboard shortcuts
Implement proper tab order
Use proper skip links
Implement proper focus traps
Implement proper error boundaries
Use proper error logging
Implement proper error recovery
Use proper error messages
Implement proper error fallbacks
Use proper form validation
Implement proper error states
Use proper error messages
Implement proper form submission
Use proper form reset
Use proper component naming
Implement proper file naming
Use proper prop naming
Implement proper...

Files:

  • packages/clerk-js/src/ui/components/UserProfile/__tests__/PasswordSection.test.tsx
  • packages/clerk-js/src/ui/elements/__tests__/PlainInput.test.tsx
  • packages/clerk-js/src/ui/elements/__tests__/RadioGroup.test.tsx
  • packages/clerk-js/src/ui/components/SignIn/__tests__/SignInFactorOne.test.tsx
  • packages/clerk-js/src/ui/components/SignIn/__tests__/SignInFactorTwo.test.tsx
packages/**/*.{test,spec}.{js,jsx,ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/monorepo.mdc)

Unit tests should use Jest or Vitest as the test runner.

Files:

  • packages/clerk-js/src/ui/components/UserProfile/__tests__/PasswordSection.test.tsx
  • packages/clerk-js/src/ui/elements/__tests__/PlainInput.test.tsx
  • packages/clerk-js/src/ui/elements/__tests__/RadioGroup.test.tsx
  • packages/clerk-js/src/ui/components/SignIn/__tests__/SignInFactorOne.test.tsx
  • packages/clerk-js/src/ui/components/SignIn/__tests__/SignInFactorTwo.test.tsx
packages/{clerk-js,elements,themes}/**/*.{test,spec}.{js,jsx,ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/monorepo.mdc)

Visual regression testing should be performed for UI components.

Files:

  • packages/clerk-js/src/ui/components/UserProfile/__tests__/PasswordSection.test.tsx
  • packages/clerk-js/src/ui/elements/__tests__/PlainInput.test.tsx
  • packages/clerk-js/src/ui/elements/__tests__/RadioGroup.test.tsx
  • packages/clerk-js/src/ui/components/SignIn/__tests__/SignInFactorOne.test.tsx
  • packages/clerk-js/src/ui/components/SignIn/__tests__/SignInFactorTwo.test.tsx
**/*.{js,ts,tsx,jsx}

📄 CodeRabbit inference engine (.cursor/rules/monorepo.mdc)

Support multiple Clerk environment variables (CLERK_, NEXT_PUBLIC_CLERK_, etc.) for configuration.

Files:

  • packages/clerk-js/src/ui/components/UserProfile/__tests__/PasswordSection.test.tsx
  • integration/tests/elements/next-sign-up.test.ts
  • integration/tests/elements/next-sign-in.test.ts
  • integration/tests/sign-up-flow.test.ts
  • packages/clerk-js/src/ui/elements/__tests__/PlainInput.test.tsx
  • packages/clerk-js/src/ui/elements/__tests__/RadioGroup.test.tsx
  • packages/clerk-js/src/ui/components/SignIn/__tests__/SignInFactorOne.test.tsx
  • integration/tests/sign-in-or-up-flow.test.ts
  • packages/clerk-js/src/ui/components/SignIn/__tests__/SignInFactorTwo.test.tsx
**/*.tsx

📄 CodeRabbit inference engine (.cursor/rules/react.mdc)

**/*.tsx: Use proper type definitions for props and state
Leverage TypeScript's type inference where possible
Use proper event types for handlers
Implement proper generic types for reusable components
Use proper type guards for conditional rendering

Files:

  • packages/clerk-js/src/ui/components/UserProfile/__tests__/PasswordSection.test.tsx
  • packages/clerk-js/src/ui/elements/__tests__/PlainInput.test.tsx
  • packages/clerk-js/src/ui/elements/__tests__/RadioGroup.test.tsx
  • packages/clerk-js/src/ui/components/SignIn/__tests__/SignInFactorOne.test.tsx
  • packages/clerk-js/src/ui/components/SignIn/__tests__/SignInFactorTwo.test.tsx
**/*.test.{jsx,tsx}

📄 CodeRabbit inference engine (.cursor/rules/react.mdc)

**/*.test.{jsx,tsx}: Use React Testing Library
Test component behavior, not implementation
Use proper test queries
Implement proper test isolation
Use proper test coverage
Test component interactions
Use proper test data
Implement proper test setup
Use proper test cleanup
Implement proper test assertions
Use proper test structure

Files:

  • packages/clerk-js/src/ui/components/UserProfile/__tests__/PasswordSection.test.tsx
  • packages/clerk-js/src/ui/elements/__tests__/PlainInput.test.tsx
  • packages/clerk-js/src/ui/elements/__tests__/RadioGroup.test.tsx
  • packages/clerk-js/src/ui/components/SignIn/__tests__/SignInFactorOne.test.tsx
  • packages/clerk-js/src/ui/components/SignIn/__tests__/SignInFactorTwo.test.tsx
**/__tests__/**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/typescript.mdc)

**/__tests__/**/*.{ts,tsx}: Create type-safe test builders/factories
Use branded types for test isolation
Implement proper mock types that match interfaces

Files:

  • packages/clerk-js/src/ui/components/UserProfile/__tests__/PasswordSection.test.tsx
  • packages/clerk-js/src/ui/elements/__tests__/PlainInput.test.tsx
  • packages/clerk-js/src/ui/elements/__tests__/RadioGroup.test.tsx
  • packages/clerk-js/src/ui/components/SignIn/__tests__/SignInFactorOne.test.tsx
  • packages/clerk-js/src/ui/components/SignIn/__tests__/SignInFactorTwo.test.tsx
integration/**

📄 CodeRabbit inference engine (.cursor/rules/global.mdc)

Framework integration templates and E2E tests should be placed under the integration/ directory

Files:

  • integration/tests/elements/next-sign-up.test.ts
  • integration/tests/elements/next-sign-in.test.ts
  • integration/tests/sign-up-flow.test.ts
  • integration/tests/sign-in-or-up-flow.test.ts
integration/**/*

📄 CodeRabbit inference engine (.cursor/rules/monorepo.mdc)

End-to-end tests and integration templates must be located in the 'integration/' directory.

Files:

  • integration/tests/elements/next-sign-up.test.ts
  • integration/tests/elements/next-sign-in.test.ts
  • integration/tests/sign-up-flow.test.ts
  • integration/tests/sign-in-or-up-flow.test.ts
integration/**/*.{test,spec}.{js,ts}

📄 CodeRabbit inference engine (.cursor/rules/monorepo.mdc)

Integration tests should use Playwright.

Files:

  • integration/tests/elements/next-sign-up.test.ts
  • integration/tests/elements/next-sign-in.test.ts
  • integration/tests/sign-up-flow.test.ts
  • integration/tests/sign-in-or-up-flow.test.ts
🧬 Code graph analysis (1)
packages/clerk-js/src/ui/components/SignIn/__tests__/SignInFactorTwo.test.tsx (1)
packages/clerk-js/src/ui/components/SignIn/SignInFactorTwo.tsx (1)
  • SignInFactorTwo (85-87)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
  • GitHub Check: Formatting | Dedupe | Changeset
  • GitHub Check: Analyze (javascript-typescript)
  • GitHub Check: semgrep-cloud-platform/scan
  • GitHub Check: semgrep-cloud-platform/scan
🔇 Additional comments (14)
integration/tests/elements/next-sign-in.test.ts (1)

169-170: LGTM! Element-based selector improves test reliability.

The shift from text-based to ID-based selectors aligns with the accessibility improvements in this PR and makes the test more robust across different rendering environments.

integration/tests/elements/next-sign-up.test.ts (1)

82-83: LGTM! Consistent with accessibility improvements.

The element-based selector approach is consistent with the changes across other test files and supports the accessibility enhancements in this PR.

integration/tests/sign-up-flow.test.ts (1)

57-58: LGTM! Robust error validation.

The explicit visibility check followed by text assertion ensures the error message is both present and correctly displayed.

integration/tests/sign-in-or-up-flow.test.ts (2)

145-146: LGTM! Selector-based approach enhances test stability.

Using the specific #error-password ID is more reliable than text-based queries, especially across different locales and rendering environments.


160-161: Consistent pattern applied correctly.

The same validation approach is used here as in the previous test case, maintaining consistency across the test suite.

packages/clerk-js/src/ui/components/UserProfile/__tests__/PasswordSection.test.tsx (3)

540-540: LGTM! More precise error query.

The change from waitFor(() => getByText(...)) to screen.findByText(..., { selector: '[id^="error-"]' }) is an improvement. It's more specific, eliminates the redundant waitFor wrapper (since findByText already waits), and targets the actual error feedback element by ID pattern.


546-546: LGTM! Proper cleanup of unused variables.

Removing getByText from the destructured render result is correct cleanup since the test now uses screen queries directly.

Also applies to: 569-569


554-554: LGTM! Consistent selector-based success feedback queries.

The updates to target success feedback using { selector: '[id$="-success-feedback"]' } are excellent. The correct use of queryByText for negative assertions and findByText for positive assertions follows React Testing Library best practices and aligns with the new FormControl implementation.

Note: Some of these changes (lines 576–586) are within a skipped test, but the updates are still valuable for future use.

Also applies to: 557-557, 576-576, 579-579, 582-582, 586-586

packages/clerk-js/src/ui/elements/__tests__/RadioGroup.test.tsx (1)

1-1: LGTM! Improved test assertions with specific selectors.

The changes correctly update assertions to use screen queries with ID-based selectors ([id^="error-"] and [id$="-info-feedback"]), ensuring feedback elements are properly identified for screen reader announcements.

Also applies to: 160-171, 191-194

packages/clerk-js/src/ui/components/SignIn/__tests__/SignInFactorOne.test.tsx (2)

189-189: LGTM! Consistent error assertion pattern.

Using the [id^="error-"] selector ensures the error message element is properly identified for screen reader announcements.


252-254: LGTM! Helpful inline documentation.

The comments clearly explain that password-pwned errors trigger navigation to a different screen, so the test strategy validates the transition rather than relying solely on error text presence.

Also applies to: 296-298, 340-342

packages/clerk-js/src/ui/elements/__tests__/PlainInput.test.tsx (3)

138-152: LGTM! Consistent selector-based assertions.

The test updates correctly use screen.findByText with specific ID selectors to validate error, info, and success feedback elements. The additions of container.querySelector verifications ensure elements have the correct IDs for aria-describedby linkage.

Also applies to: 163-167, 177-191, 201-223


225-248: LGTM! Pre-state validation addresses previous review feedback.

The test properly validates the initial state before triggering feedback changes—ensuring the aria-live region exists, is empty, and is visually hidden. This confirms that subsequent announcements are actual changes, which is essential for aria-live functionality. Based on learnings


250-283: LGTM! Comprehensive validation of live region updates.

The test thoroughly validates that the aria-live region announces feedback changes (error → success) and that visible feedback elements maintain proper IDs for aria-describedby. The visibility checks during transitions (lines 278-282) appropriately handle animation states.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

♻️ Duplicate comments (1)
integration/tests/sign-in-flow.test.ts (1)

146-147: Same accessibility verification recommendation applies here.

As noted in the previous test case, consider adding assertions to verify the ARIA live region and aria-describedby attributes to ensure the accessibility improvements are working correctly.

🧹 Nitpick comments (1)
integration/tests/sign-in-flow.test.ts (1)

131-132: Consider verifying the accessibility features introduced in this PR.

The selector-based assertions are correct and improve test robustness. However, these tests don't verify the core accessibility improvements mentioned in the PR objectives:

  • The ARIA live region that announces errors to screen readers
  • The aria-describedby attribute linking the input to the error message

Consider adding assertions to verify these accessibility features, for example:

// Verify aria-describedby links password input to error
const passwordInput = u.page.locator('input[name="password"]');
await expect(passwordInput).toHaveAttribute('aria-describedby', expect.stringContaining('error-password'));

// Verify live region exists and contains the error
const liveRegion = u.page.locator('[role="status"][aria-live="polite"]');
await expect(liveRegion).toContainText(/password is incorrect/i);
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between ab5466e and 31b7ffd.

📒 Files selected for processing (5)
  • integration/tests/elements/next-sign-in.test.ts (2 hunks)
  • integration/tests/elements/next-sign-up.test.ts (1 hunks)
  • integration/tests/sign-in-flow.test.ts (2 hunks)
  • integration/tests/sign-in-or-up-flow.test.ts (2 hunks)
  • integration/tests/sign-up-flow.test.ts (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • integration/tests/elements/next-sign-up.test.ts
  • integration/tests/elements/next-sign-in.test.ts
🧰 Additional context used
📓 Path-based instructions (7)
**/*.{js,jsx,ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

**/*.{js,jsx,ts,tsx}: All code must pass ESLint checks with the project's configuration
Follow established naming conventions (PascalCase for components, camelCase for variables)
Maintain comprehensive JSDoc comments for public APIs
Use dynamic imports for optional features
All public APIs must be documented with JSDoc
Provide meaningful error messages to developers
Include error recovery suggestions where applicable
Log errors appropriately for debugging
Lazy load components and features when possible
Implement proper caching strategies
Use efficient data structures and algorithms
Profile and optimize critical paths
Validate all inputs and sanitize outputs
Implement proper logging with different levels

Files:

  • integration/tests/sign-in-or-up-flow.test.ts
  • integration/tests/sign-up-flow.test.ts
  • integration/tests/sign-in-flow.test.ts
**/*.{js,jsx,ts,tsx,json,css,scss,md,yaml,yml}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

Use Prettier for consistent code formatting

Files:

  • integration/tests/sign-in-or-up-flow.test.ts
  • integration/tests/sign-up-flow.test.ts
  • integration/tests/sign-in-flow.test.ts
**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

Use proper TypeScript error types

**/*.{ts,tsx}: Always define explicit return types for functions, especially public APIs
Use proper type annotations for variables and parameters where inference isn't clear
Avoid any type - prefer unknown when type is uncertain, then narrow with type guards
Use interface for object shapes that might be extended
Use type for unions, primitives, and computed types
Prefer readonly properties for immutable data structures
Use private for internal implementation details
Use protected for inheritance hierarchies
Use public explicitly for clarity in public APIs
Prefer readonly for properties that shouldn't change after construction
Prefer composition and interfaces over deep inheritance chains
Use mixins for shared behavior across unrelated classes
Implement dependency injection for loose coupling
Let TypeScript infer when types are obvious
Use const assertions for literal types: as const
Use satisfies operator for type checking without widening
Use mapped types for transforming object types
Use conditional types for type-level logic
Leverage template literal types for string manipulation
Use ES6 imports/exports consistently
Use default exports sparingly, prefer named exports
Use type-only imports: import type { ... } from ...
No any types without justification
Proper error handling with typed errors
Consistent use of readonly for immutable data
Proper generic constraints
No unused type parameters
Proper use of utility types instead of manual type construction
Type-only imports where possible
Proper tree-shaking friendly exports
No circular dependencies
Efficient type computations (avoid deep recursion)

Files:

  • integration/tests/sign-in-or-up-flow.test.ts
  • integration/tests/sign-up-flow.test.ts
  • integration/tests/sign-in-flow.test.ts
integration/**

📄 CodeRabbit inference engine (.cursor/rules/global.mdc)

Framework integration templates and E2E tests should be placed under the integration/ directory

Files:

  • integration/tests/sign-in-or-up-flow.test.ts
  • integration/tests/sign-up-flow.test.ts
  • integration/tests/sign-in-flow.test.ts
integration/**/*

📄 CodeRabbit inference engine (.cursor/rules/monorepo.mdc)

End-to-end tests and integration templates must be located in the 'integration/' directory.

Files:

  • integration/tests/sign-in-or-up-flow.test.ts
  • integration/tests/sign-up-flow.test.ts
  • integration/tests/sign-in-flow.test.ts
integration/**/*.{test,spec}.{js,ts}

📄 CodeRabbit inference engine (.cursor/rules/monorepo.mdc)

Integration tests should use Playwright.

Files:

  • integration/tests/sign-in-or-up-flow.test.ts
  • integration/tests/sign-up-flow.test.ts
  • integration/tests/sign-in-flow.test.ts
**/*.{js,ts,tsx,jsx}

📄 CodeRabbit inference engine (.cursor/rules/monorepo.mdc)

Support multiple Clerk environment variables (CLERK_, NEXT_PUBLIC_CLERK_, etc.) for configuration.

Files:

  • integration/tests/sign-in-or-up-flow.test.ts
  • integration/tests/sign-up-flow.test.ts
  • integration/tests/sign-in-flow.test.ts
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (29)
  • GitHub Check: Integration Tests (quickstart, chrome, 15)
  • GitHub Check: Integration Tests (machine, chrome)
  • GitHub Check: Integration Tests (nextjs, chrome, 16)
  • GitHub Check: Integration Tests (quickstart, chrome, 16)
  • GitHub Check: Integration Tests (nextjs, chrome, 14)
  • GitHub Check: Integration Tests (nextjs, chrome, 15)
  • GitHub Check: Integration Tests (custom, chrome)
  • GitHub Check: Integration Tests (astro, chrome)
  • GitHub Check: Integration Tests (billing, chrome)
  • GitHub Check: Integration Tests (sessions:staging, chrome)
  • GitHub Check: Integration Tests (handshake:staging, chrome)
  • GitHub Check: Integration Tests (vue, chrome)
  • GitHub Check: Integration Tests (generic, chrome)
  • GitHub Check: Integration Tests (react-router, chrome)
  • GitHub Check: Integration Tests (sessions, chrome)
  • GitHub Check: Integration Tests (expo-web, chrome)
  • GitHub Check: Integration Tests (nuxt, chrome)
  • GitHub Check: Integration Tests (tanstack-react-start, chrome)
  • GitHub Check: Integration Tests (handshake, chrome)
  • GitHub Check: Integration Tests (localhost, chrome)
  • GitHub Check: Integration Tests (ap-flows, chrome)
  • GitHub Check: Integration Tests (elements, chrome)
  • GitHub Check: Integration Tests (express, chrome)
  • GitHub Check: Publish with pkg-pr-new
  • GitHub Check: Static analysis
  • GitHub Check: Unit Tests (22, **)
  • GitHub Check: Analyze (javascript-typescript)
  • GitHub Check: semgrep-cloud-platform/scan
  • GitHub Check: semgrep-cloud-platform/scan
🔇 Additional comments (2)
integration/tests/sign-in-or-up-flow.test.ts (1)

145-146: Improved test specificity with element-based selectors.

The change from text-based queries to targeting #error-password directly is more robust and aligns well with the accessibility improvements in this PR. The two-step assertion (visibility + content) provides better test coverage than a single text check.

Also applies to: 160-161

integration/tests/sign-up-flow.test.ts (1)

57-58: LGTM! Consistent selector pattern for password validation.

The change to use #error-password with explicit visibility and content checks follows the same robust pattern as the sign-in tests. This ensures password validation errors are properly displayed and accessible.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
packages/clerk-js/src/ui/components/SignIn/__tests__/SignInFactorTwo.test.tsx (2)

164-189: Test expectation doesn't match mocked error response.

The mock at line 178 returns long_message: 'Incorrect phone code', but line 188 expects to find the text 'Incorrect authenticator code'. This mismatch will cause the test to fail.

Apply this diff to fix the test expectation:

-        expect(await screen.findByText('Incorrect authenticator code')).toBeDefined();
+        expect(await screen.findByText('Incorrect phone code')).toBeDefined();

254-278: Test expectation doesn't match mocked error response.

The mock at line 267 returns long_message: 'Incorrect authenticator code', but line 277 expects to find the text 'Incorrect phone code'. This mismatch will cause the test to fail.

Apply this diff to fix the test expectation:

-        expect(await screen.findByText('Incorrect phone code')).toBeDefined();
+        expect(await screen.findByText('Incorrect authenticator code')).toBeDefined();
🧹 Nitpick comments (4)
packages/clerk-js/src/ui/elements/__tests__/RadioGroup.test.tsx (3)

1-1: Remove unused screen import.

The screen import is not used anywhere in this test file.

Apply this diff:

-import { fireEvent, render, screen, waitFor } from '@testing-library/react';
+import { fireEvent, render, waitFor } from '@testing-library/react';

171-173: Consider verifying error message content.

The test now verifies the error element exists by ID, which correctly validates the ARIA structure. However, it should also verify that the error element contains the expected text "some error" to ensure the message is actually displayed.

Apply this diff to also check the text content:

 await waitFor(() => {
-  expect(container.querySelector('#error-some-radio')).toBeInTheDocument();
+  const errorElement = container.querySelector('#error-some-radio');
+  expect(errorElement).toBeInTheDocument();
+  expect(errorElement).toHaveTextContent('some error');
 });

196-198: Consider verifying info message content.

Similar to the error test, this assertion validates the info element exists by ID but doesn't verify the actual message content. The test should confirm that "some info" text is displayed.

Apply this diff to also check the text content:

 await waitFor(() => {
-  expect(container.querySelector('#some-radio-info-feedback')).toBeInTheDocument();
+  const infoElement = container.querySelector('#some-radio-info-feedback');
+  expect(infoElement).toBeInTheDocument();
+  expect(infoElement).toHaveTextContent('some info');
 });
packages/clerk-js/src/ui/elements/__tests__/PlainInput.test.tsx (1)

1-1: Remove unused screen import.

The screen import is added but never used in the test file. All queries use destructured methods from render() or container.querySelector().

Apply this diff to remove the unused import:

-import { fireEvent, render, screen, waitFor } from '@testing-library/react';
+import { fireEvent, render, waitFor } from '@testing-library/react';
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 31b7ffd and 06c3611.

📒 Files selected for processing (4)
  • packages/clerk-js/src/ui/components/SignIn/__tests__/SignInFactorOne.test.tsx (1 hunks)
  • packages/clerk-js/src/ui/components/SignIn/__tests__/SignInFactorTwo.test.tsx (2 hunks)
  • packages/clerk-js/src/ui/elements/__tests__/PlainInput.test.tsx (6 hunks)
  • packages/clerk-js/src/ui/elements/__tests__/RadioGroup.test.tsx (4 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/clerk-js/src/ui/components/SignIn/tests/SignInFactorOne.test.tsx
🧰 Additional context used
📓 Path-based instructions (13)
packages/clerk-js/src/ui/**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/clerk-js-ui.mdc)

packages/clerk-js/src/ui/**/*.{ts,tsx}: Element descriptors should always be camelCase
Use element descriptors in UI components to enable consistent theming and styling via appearance.elements
Element descriptors should generate unique, stable CSS classes for theming
Element descriptors should handle state classes (e.g., cl-loading, cl-active, cl-error, cl-open) automatically based on component state
Do not render hard-coded values; all user-facing strings must be localized using provided localization methods
Use the useLocalizations hook and localizationKeys utility for all text and error messages
Use the styled system (sx prop, theme tokens, responsive values) for custom component styling
Use useCardState for card-level state, useFormState for form-level state, and useLoadingStatus for loading states
Always use handleError utility for API errors and use translateError for localized error messages
Use useFormControl for form field state, implement proper validation, and handle loading and error states in forms
Use localization keys for all form labels and placeholders
Use element descriptors for consistent styling and follow the theme token system
Use the Card and FormContainer patterns for consistent UI structure

Files:

  • packages/clerk-js/src/ui/elements/__tests__/RadioGroup.test.tsx
  • packages/clerk-js/src/ui/elements/__tests__/PlainInput.test.tsx
  • packages/clerk-js/src/ui/components/SignIn/__tests__/SignInFactorTwo.test.tsx
**/*.{js,jsx,ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

**/*.{js,jsx,ts,tsx}: All code must pass ESLint checks with the project's configuration
Follow established naming conventions (PascalCase for components, camelCase for variables)
Maintain comprehensive JSDoc comments for public APIs
Use dynamic imports for optional features
All public APIs must be documented with JSDoc
Provide meaningful error messages to developers
Include error recovery suggestions where applicable
Log errors appropriately for debugging
Lazy load components and features when possible
Implement proper caching strategies
Use efficient data structures and algorithms
Profile and optimize critical paths
Validate all inputs and sanitize outputs
Implement proper logging with different levels

Files:

  • packages/clerk-js/src/ui/elements/__tests__/RadioGroup.test.tsx
  • packages/clerk-js/src/ui/elements/__tests__/PlainInput.test.tsx
  • packages/clerk-js/src/ui/components/SignIn/__tests__/SignInFactorTwo.test.tsx
**/*.{js,jsx,ts,tsx,json,css,scss,md,yaml,yml}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

Use Prettier for consistent code formatting

Files:

  • packages/clerk-js/src/ui/elements/__tests__/RadioGroup.test.tsx
  • packages/clerk-js/src/ui/elements/__tests__/PlainInput.test.tsx
  • packages/clerk-js/src/ui/components/SignIn/__tests__/SignInFactorTwo.test.tsx
packages/**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

TypeScript is required for all packages

Files:

  • packages/clerk-js/src/ui/elements/__tests__/RadioGroup.test.tsx
  • packages/clerk-js/src/ui/elements/__tests__/PlainInput.test.tsx
  • packages/clerk-js/src/ui/components/SignIn/__tests__/SignInFactorTwo.test.tsx
packages/**/*.{ts,tsx,d.ts}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

Packages should export TypeScript types alongside runtime code

Files:

  • packages/clerk-js/src/ui/elements/__tests__/RadioGroup.test.tsx
  • packages/clerk-js/src/ui/elements/__tests__/PlainInput.test.tsx
  • packages/clerk-js/src/ui/components/SignIn/__tests__/SignInFactorTwo.test.tsx
**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

Use proper TypeScript error types

**/*.{ts,tsx}: Always define explicit return types for functions, especially public APIs
Use proper type annotations for variables and parameters where inference isn't clear
Avoid any type - prefer unknown when type is uncertain, then narrow with type guards
Use interface for object shapes that might be extended
Use type for unions, primitives, and computed types
Prefer readonly properties for immutable data structures
Use private for internal implementation details
Use protected for inheritance hierarchies
Use public explicitly for clarity in public APIs
Prefer readonly for properties that shouldn't change after construction
Prefer composition and interfaces over deep inheritance chains
Use mixins for shared behavior across unrelated classes
Implement dependency injection for loose coupling
Let TypeScript infer when types are obvious
Use const assertions for literal types: as const
Use satisfies operator for type checking without widening
Use mapped types for transforming object types
Use conditional types for type-level logic
Leverage template literal types for string manipulation
Use ES6 imports/exports consistently
Use default exports sparingly, prefer named exports
Use type-only imports: import type { ... } from ...
No any types without justification
Proper error handling with typed errors
Consistent use of readonly for immutable data
Proper generic constraints
No unused type parameters
Proper use of utility types instead of manual type construction
Type-only imports where possible
Proper tree-shaking friendly exports
No circular dependencies
Efficient type computations (avoid deep recursion)

Files:

  • packages/clerk-js/src/ui/elements/__tests__/RadioGroup.test.tsx
  • packages/clerk-js/src/ui/elements/__tests__/PlainInput.test.tsx
  • packages/clerk-js/src/ui/components/SignIn/__tests__/SignInFactorTwo.test.tsx
**/*.{jsx,tsx}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

**/*.{jsx,tsx}: Use error boundaries in React components
Minimize re-renders in React components

**/*.{jsx,tsx}: Always use functional components with hooks instead of class components
Follow PascalCase naming for components: UserProfile, NavigationMenu
Keep components focused on a single responsibility - split large components
Limit component size to 150-200 lines; extract logic into custom hooks
Use composition over inheritance - prefer smaller, composable components
Export components as named exports for better tree-shaking
One component per file with matching filename and component name
Use useState for simple state management
Use useReducer for complex state logic
Implement proper state initialization
Use proper state updates with callbacks
Implement proper state cleanup
Use Context API for theme/authentication
Implement proper state selectors
Use proper state normalization
Implement proper state persistence
Use React.memo for expensive components
Implement proper useCallback for handlers
Use proper useMemo for expensive computations
Implement proper virtualization for lists
Use proper code splitting with React.lazy
Implement proper cleanup in useEffect
Use proper refs for DOM access
Implement proper event listener cleanup
Use proper abort controllers for fetch
Implement proper subscription cleanup
Use proper HTML elements
Implement proper ARIA attributes
Use proper heading hierarchy
Implement proper form labels
Use proper button types
Implement proper focus management
Use proper keyboard shortcuts
Implement proper tab order
Use proper skip links
Implement proper focus traps
Implement proper error boundaries
Use proper error logging
Implement proper error recovery
Use proper error messages
Implement proper error fallbacks
Use proper form validation
Implement proper error states
Use proper error messages
Implement proper form submission
Use proper form reset
Use proper component naming
Implement proper file naming
Use proper prop naming
Implement proper...

Files:

  • packages/clerk-js/src/ui/elements/__tests__/RadioGroup.test.tsx
  • packages/clerk-js/src/ui/elements/__tests__/PlainInput.test.tsx
  • packages/clerk-js/src/ui/components/SignIn/__tests__/SignInFactorTwo.test.tsx
packages/**/*.{test,spec}.{js,jsx,ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/monorepo.mdc)

Unit tests should use Jest or Vitest as the test runner.

Files:

  • packages/clerk-js/src/ui/elements/__tests__/RadioGroup.test.tsx
  • packages/clerk-js/src/ui/elements/__tests__/PlainInput.test.tsx
  • packages/clerk-js/src/ui/components/SignIn/__tests__/SignInFactorTwo.test.tsx
packages/{clerk-js,elements,themes}/**/*.{test,spec}.{js,jsx,ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/monorepo.mdc)

Visual regression testing should be performed for UI components.

Files:

  • packages/clerk-js/src/ui/elements/__tests__/RadioGroup.test.tsx
  • packages/clerk-js/src/ui/elements/__tests__/PlainInput.test.tsx
  • packages/clerk-js/src/ui/components/SignIn/__tests__/SignInFactorTwo.test.tsx
**/*.{js,ts,tsx,jsx}

📄 CodeRabbit inference engine (.cursor/rules/monorepo.mdc)

Support multiple Clerk environment variables (CLERK_, NEXT_PUBLIC_CLERK_, etc.) for configuration.

Files:

  • packages/clerk-js/src/ui/elements/__tests__/RadioGroup.test.tsx
  • packages/clerk-js/src/ui/elements/__tests__/PlainInput.test.tsx
  • packages/clerk-js/src/ui/components/SignIn/__tests__/SignInFactorTwo.test.tsx
**/*.tsx

📄 CodeRabbit inference engine (.cursor/rules/react.mdc)

**/*.tsx: Use proper type definitions for props and state
Leverage TypeScript's type inference where possible
Use proper event types for handlers
Implement proper generic types for reusable components
Use proper type guards for conditional rendering

Files:

  • packages/clerk-js/src/ui/elements/__tests__/RadioGroup.test.tsx
  • packages/clerk-js/src/ui/elements/__tests__/PlainInput.test.tsx
  • packages/clerk-js/src/ui/components/SignIn/__tests__/SignInFactorTwo.test.tsx
**/*.test.{jsx,tsx}

📄 CodeRabbit inference engine (.cursor/rules/react.mdc)

**/*.test.{jsx,tsx}: Use React Testing Library
Test component behavior, not implementation
Use proper test queries
Implement proper test isolation
Use proper test coverage
Test component interactions
Use proper test data
Implement proper test setup
Use proper test cleanup
Implement proper test assertions
Use proper test structure

Files:

  • packages/clerk-js/src/ui/elements/__tests__/RadioGroup.test.tsx
  • packages/clerk-js/src/ui/elements/__tests__/PlainInput.test.tsx
  • packages/clerk-js/src/ui/components/SignIn/__tests__/SignInFactorTwo.test.tsx
**/__tests__/**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/typescript.mdc)

**/__tests__/**/*.{ts,tsx}: Create type-safe test builders/factories
Use branded types for test isolation
Implement proper mock types that match interfaces

Files:

  • packages/clerk-js/src/ui/elements/__tests__/RadioGroup.test.tsx
  • packages/clerk-js/src/ui/elements/__tests__/PlainInput.test.tsx
  • packages/clerk-js/src/ui/components/SignIn/__tests__/SignInFactorTwo.test.tsx
🧬 Code graph analysis (1)
packages/clerk-js/src/ui/elements/__tests__/PlainInput.test.tsx (1)
packages/clerk-js/src/ui/elements/FieldControl.tsx (1)
  • Field (294-312)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
  • GitHub Check: Formatting | Dedupe | Changeset
  • GitHub Check: Analyze (javascript-typescript)
  • GitHub Check: semgrep-cloud-platform/scan
  • GitHub Check: semgrep-cloud-platform/scan
🔇 Additional comments (4)
packages/clerk-js/src/ui/elements/__tests__/PlainInput.test.tsx (4)

130-171: LGTM: Proper async assertions and ARIA attribute verification.

The updated tests correctly use waitFor to handle async feedback rendering and verify both the presence of feedback elements (via ID selectors) and their ARIA linkage. This pattern ensures the tests wait for DOM updates before asserting.


199-233: LGTM: Thorough transition testing.

The test properly verifies state transitions between error and success feedback, including ARIA attribute updates. The use of waitFor for both transitions ensures robust async handling.


235-258: Excellent pre-state verification addresses previous review feedback.

The pre-state checks (lines 245-253) directly address Ephem's comment about verifying the aria-live region exists before setting errors, since aria-live only announces changes. The test correctly:

  • Verifies the aria-live region exists initially
  • Confirms it starts empty
  • Checks the input has no error state or aria-describedby yet

Based on learnings


287-296: Clarify visibility assertion logic.

The comment states "One should be visible, the other hidden (for animation)" but the assertion only checks that at least one is visible. This logic seems contradictory:

// Comment suggests exclusive visibility
// One should be visible, the other hidden (for animation)

// But assertion allows both
expect(errorVisible || successVisible).toBe(true);

What is the actual expected behavior here?

  • Should exactly one be visible at a time?
  • Can both be visible during transition?
  • Is this testing animation behavior, which might be flaky?

If the goal is to verify that feedback elements have proper IDs for aria-describedby regardless of transition state, consider simplifying to just verify the elements exist with correct IDs, rather than checking computed visibility styles.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
integration/tests/sign-in-or-up-restricted-mode.test.ts (1)

36-37: LGTM! Test correctly uses the new test ID for form feedback.

The migration from text-based selectors to form-feedback-error test ID improves test robustness and aligns with the PR's accessibility improvements.

Optional: Reduce selector duplication.

Consider extracting the element to a variable:

+    const errorFeedback = u.page.getByTestId('form-feedback-error');
+    await expect(errorFeedback).toBeVisible();
+    await expect(errorFeedback).toHaveText(/Couldn't find your account\./i);
-    await expect(u.page.getByTestId('form-feedback-error')).toBeVisible();
-    await expect(u.page.getByTestId('form-feedback-error')).toHaveText(/Couldn't find your account\./i);
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 97a97b8 and f1b4cfc.

📒 Files selected for processing (1)
  • integration/tests/sign-in-or-up-restricted-mode.test.ts (1 hunks)
🧰 Additional context used
📓 Path-based instructions (7)
**/*.{js,jsx,ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

**/*.{js,jsx,ts,tsx}: All code must pass ESLint checks with the project's configuration
Follow established naming conventions (PascalCase for components, camelCase for variables)
Maintain comprehensive JSDoc comments for public APIs
Use dynamic imports for optional features
All public APIs must be documented with JSDoc
Provide meaningful error messages to developers
Include error recovery suggestions where applicable
Log errors appropriately for debugging
Lazy load components and features when possible
Implement proper caching strategies
Use efficient data structures and algorithms
Profile and optimize critical paths
Validate all inputs and sanitize outputs
Implement proper logging with different levels

Files:

  • integration/tests/sign-in-or-up-restricted-mode.test.ts
**/*.{js,jsx,ts,tsx,json,css,scss,md,yaml,yml}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

Use Prettier for consistent code formatting

Files:

  • integration/tests/sign-in-or-up-restricted-mode.test.ts
**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

Use proper TypeScript error types

**/*.{ts,tsx}: Always define explicit return types for functions, especially public APIs
Use proper type annotations for variables and parameters where inference isn't clear
Avoid any type - prefer unknown when type is uncertain, then narrow with type guards
Use interface for object shapes that might be extended
Use type for unions, primitives, and computed types
Prefer readonly properties for immutable data structures
Use private for internal implementation details
Use protected for inheritance hierarchies
Use public explicitly for clarity in public APIs
Prefer readonly for properties that shouldn't change after construction
Prefer composition and interfaces over deep inheritance chains
Use mixins for shared behavior across unrelated classes
Implement dependency injection for loose coupling
Let TypeScript infer when types are obvious
Use const assertions for literal types: as const
Use satisfies operator for type checking without widening
Use mapped types for transforming object types
Use conditional types for type-level logic
Leverage template literal types for string manipulation
Use ES6 imports/exports consistently
Use default exports sparingly, prefer named exports
Use type-only imports: import type { ... } from ...
No any types without justification
Proper error handling with typed errors
Consistent use of readonly for immutable data
Proper generic constraints
No unused type parameters
Proper use of utility types instead of manual type construction
Type-only imports where possible
Proper tree-shaking friendly exports
No circular dependencies
Efficient type computations (avoid deep recursion)

Files:

  • integration/tests/sign-in-or-up-restricted-mode.test.ts
integration/**

📄 CodeRabbit inference engine (.cursor/rules/global.mdc)

Framework integration templates and E2E tests should be placed under the integration/ directory

Files:

  • integration/tests/sign-in-or-up-restricted-mode.test.ts
integration/**/*

📄 CodeRabbit inference engine (.cursor/rules/monorepo.mdc)

End-to-end tests and integration templates must be located in the 'integration/' directory.

Files:

  • integration/tests/sign-in-or-up-restricted-mode.test.ts
integration/**/*.{test,spec}.{js,ts}

📄 CodeRabbit inference engine (.cursor/rules/monorepo.mdc)

Integration tests should use Playwright.

Files:

  • integration/tests/sign-in-or-up-restricted-mode.test.ts
**/*.{js,ts,tsx,jsx}

📄 CodeRabbit inference engine (.cursor/rules/monorepo.mdc)

Support multiple Clerk environment variables (CLERK_, NEXT_PUBLIC_CLERK_, etc.) for configuration.

Files:

  • integration/tests/sign-in-or-up-restricted-mode.test.ts
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (30)
  • GitHub Check: Integration Tests (nextjs, chrome, 16)
  • GitHub Check: Integration Tests (quickstart, chrome, 16)
  • GitHub Check: Integration Tests (quickstart, chrome, 15)
  • GitHub Check: Integration Tests (nextjs, chrome, 14)
  • GitHub Check: Integration Tests (machine, chrome)
  • GitHub Check: Integration Tests (custom, chrome)
  • GitHub Check: Integration Tests (react-router, chrome)
  • GitHub Check: Integration Tests (billing, chrome)
  • GitHub Check: Integration Tests (nextjs, chrome, 15)
  • GitHub Check: Integration Tests (expo-web, chrome)
  • GitHub Check: Integration Tests (vue, chrome)
  • GitHub Check: Integration Tests (tanstack-react-start, chrome)
  • GitHub Check: Integration Tests (astro, chrome)
  • GitHub Check: Integration Tests (nuxt, chrome)
  • GitHub Check: Integration Tests (handshake, chrome)
  • GitHub Check: Integration Tests (localhost, chrome)
  • GitHub Check: Integration Tests (handshake:staging, chrome)
  • GitHub Check: Integration Tests (sessions:staging, chrome)
  • GitHub Check: Integration Tests (sessions, chrome)
  • GitHub Check: Integration Tests (elements, chrome)
  • GitHub Check: Integration Tests (ap-flows, chrome)
  • GitHub Check: Integration Tests (generic, chrome)
  • GitHub Check: Integration Tests (express, chrome)
  • GitHub Check: Static analysis
  • GitHub Check: Publish with pkg-pr-new
  • GitHub Check: Unit Tests (22, **)
  • GitHub Check: Formatting | Dedupe | Changeset
  • GitHub Check: Analyze (javascript-typescript)
  • GitHub Check: semgrep-cloud-platform/scan
  • GitHub Check: semgrep-cloud-platform/scan

@alexcarpenter alexcarpenter merged commit f0c3a55 into main Nov 6, 2025
63 of 69 checks passed
@alexcarpenter alexcarpenter deleted the alexcarpenter/user-3837-form-errors-not-being-announced-by-screen-readers branch November 6, 2025 13:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants